package com.example.tactics.standby;

import com.example.tactics.AreaType;
import com.example.tactics.note.Areaset;
import com.example.tactics.service.Excelhandle;
import com.example.tactics.service.Impl.HuaianExcelImpl;
import com.example.tactics.service.Impl.SuzhoExcelImpl;
import com.example.tactics.service.Impl.WuxiExcelImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.util.CollectionUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * description : 定义策略实现
 * author :kang
 * create :2021-10-22 18:09:00
 */
public class ExcelTacticsStan {

    //获取自定义注解里的类
    private ApplicationContext applicationContext;

    //装策略模式的
    private static Map<AreaType, Excelhandle> excelhandleMap = new HashMap<>();

    /**
     * 把几个模块装到工厂里
     */
    static {
        excelhandleMap.put(AreaType.SUZHO, new SuzhoExcelImpl());
        excelhandleMap.put(AreaType.WUXI, new WuxiExcelImpl());
        excelhandleMap.put(AreaType.HUAIAN, new HuaianExcelImpl());
    }

    /**
     * 从工厂里获取策略,根据自定义注解，拿到每个地区的类
     *
     * @param areaType 判断的值
     * @return
     */
    public static Excelhandle getExcelhandle(AreaType areaType) {
        return excelhandleMap.get(areaType);
    }

}
